<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

	<f:view>
		<f:loadBundle basename="tvseries.Messages" var="msgs" />

		<head>
			<base href="<%=basePath%>"/>

			<title><h:outputText value="#{msgs['app.title']}" /></title>

			<meta http-equiv="pragma" content="no-cache">
			<meta http-equiv="cache-control" content="no-cache">
			<meta http-equiv="expires" content="0">
			<meta http-equiv="description" content="<h:outputText value="#{msgs['app.description']}"/>">
			<link rel="stylesheet" type="text/css" href="<%=basePath%>styles.css">
		</head>

		<body>
			<h:form id="main">
				<h:panelGrid align="center" columns="2" styleClass="mainview" headerClass="pageHeader" footerClass="pageFooter"
					columnClasses="menuColumn, contentColumn">

					<f:facet name="header">
						<f:subview id="header">
							<c:import url="/view/header.jsp" />
						</f:subview>
					</f:facet>

					<f:subview id="menu">
						<c:import url="/view/menu.jsp" />
					</f:subview>

					<f:subview id="content">
						<%/* CONTENT BEGIN */%>
						<h:panelGrid columns="1" styleClass="content" headerClass="contentHeader" footerClass="contentFooter">

							<f:facet name="header">
								<h:panelGroup>
									<h:outputText value="#{tvSeries.title}" styleClass="title" />
									<f:verbatim>
										<hr />
									</f:verbatim>
									<h:messages />
								</h:panelGroup>
							</f:facet>

							<h:panelGrid columns="2" columnClasses="labelColumn,dataColumn">
								<h:outputText value="#{msgs['view.series.detail.label.imdbid']}" />
								<h:outputLink value="#{tvSeries.imdbUrl}"><h:outputText value="#{tvSeries.id}" /></h:outputLink>
								<h:outputText value="#{msgs['view.series.detail.label.lastUpdate']}" />
								<h:outputText value="#{tvSeries.lastUpdate}" />
								<h:outputText value="#{msgs['view.series.detail.label.summary']}" />
								<h:outputText value="#{tvSeries.summary}" />
							</h:panelGrid>

							<f:verbatim><hr/></f:verbatim>
							<h:panelGroup>
								<h:outputText value="Show types of episodes: " style="font-size: 12px;"/>
								<h:selectBooleanCheckbox style="vertical-align: middle;" title="showAvailable" value="#{tvSeries.showAvailable}" onchange="this.form.submit()" />
								<h:outputText value="Available" style="font-size: 12px; padding-right: 15px;"/>
								<h:selectBooleanCheckbox style="vertical-align: middle;" title="showMissing" value="#{tvSeries.showMissing}" onchange="this.form.submit()" />
								<h:outputText value="Missing" style="font-size: 12px; padding-right: 15px;"/>
								<h:selectBooleanCheckbox style="vertical-align: middle;" title="showArchived" value="#{tvSeries.showArchived}" onchange="this.form.submit()" />
								<h:outputText value="Archived" style="font-size: 12px; padding-right: 15px;"/>
								<h:selectBooleanCheckbox style="vertical-align: middle;" title="showIgnored" value="#{tvSeries.showIgnored}" onchange="this.form.submit()" />
								<h:outputText value="Ignored" style="font-size: 12px; padding-right: 15px;"/>
							</h:panelGroup>

							<h:dataTable id="episodeList" styleClass="dataTable" rowClasses="boxedRow" columnClasses="titleColumn,smallDataCenterColumn,smallDataCenterColumn,smallDataCenterColumn,medDataCenterColumn,smallDataCenterColumn" footerClass="centerColumn" frame="border" value="#{tvSeries.episodeList}" var="episode">
								<h:column>
									<f:facet name="header">
										<h:outputText value="#{msgs['view.series.detail.column.title']}"/>
									</f:facet>
									<h:commandLink value="#{episode.title}" action="#{tvSeries.viewEpisode}">
										<f:param name="episodeId" value="#{episode.id}"/>
									</h:commandLink>
								</h:column>
								<h:column>
									<f:facet name="header">
										<h:outputText value="#{msgs['view.series.detail.column.season']}"/>
									</f:facet>
									<h:outputText value="#{episode.season}"/>
								</h:column>
								<h:column>
									<f:facet name="header">
										<h:outputText value="#{msgs['view.series.detail.column.episode']}"/>
									</f:facet>
									<h:outputText value="#{episode.episode}"/>
								</h:column>
								<h:column>
									<f:facet name="header">
										<h:outputText value="#{msgs['view.series.detail.column.status']}"/>
									</f:facet>
									<h:outputText value="#{episode.status}" rendered="#{episode.status eq 'Archived'}" style="color: #000000" />
									<h:outputText value="#{episode.status}" rendered="#{episode.status eq 'Available'}" style="color: #007700" />
									<h:outputText value="#{episode.status}" rendered="#{episode.status eq 'Ignored'}" style="color: #AAAAAA" />
									<h:outputText value="#{episode.status}" rendered="#{episode.status eq 'Missing'}" style="color: #770000" />
								</h:column>
								<h:column>
									<f:facet name="header">
										<h:outputText value="#{msgs['view.series.detail.column.airDate']}"/>
									</f:facet>
									<h:outputText value="#{episode.airDate}"/>
								</h:column>
								<h:column>
									<f:facet name="header">
										<h:panelGroup>
											<h:commandLink styleClass="commandLink" id="selectAllCommand" value="select all" action="#{tvSeries.selectAllEpisodes}" immediate="true"/>
											<f:verbatim><br/></f:verbatim>
											<h:commandLink styleClass="commandLink" id="deselectAllCommand" value="deselect all" action="#{tvSeries.deselectAllEpisodes}" immediate="true"/>
										</h:panelGroup>
									</f:facet>
									<h:selectBooleanCheckbox id="policySelect" value="#{episode.selected}"/>
								</h:column>
							</h:dataTable>

							<f:facet name="footer">
								<h:panelGroup>
									<h:commandButton value="change status" action="#{tvSeries.changeStatus}"/>
									<h:selectOneMenu id="statusChangeSelect" value="#{tvSeries.episodeStatus}">
										<f:selectItem itemValue="Archived" itemLabel="Archived" />
										<f:selectItem itemValue="Automatic" itemLabel="Automatic" />
										<f:selectItem itemValue="Ignored" itemLabel="Ignored" />
									</h:selectOneMenu>
								</h:panelGroup>
							</f:facet>

						</h:panelGrid>
						<%/* CONTENT END */%>
					</f:subview>

					<f:facet name="footer">
						<f:subview id="footer">
							<c:import url="/view/footer.jsp" />
						</f:subview>
					</f:facet>

				</h:panelGrid>
			</h:form>
		</body>
	</f:view>

</html>
